﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="ExaminationSys.Index" MasterPageFile="~/View/Share/Index.Master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentHolder" runat="server">
<style type="text/css" >
    .side .box203 .titles,.home-right .home-genius dt{overflow:visible;}
</style>
<script src="js/jquery.js" type="text/javascript"></script>
 <script language="javascript" type="text/javascript">
     function getimgcode() {
         var getimagecode = document.getElementById("getcode");
         getimagecode.src = "VerifyCode.aspx?time='+Math.random();";
     }
     $(function () {
         $("#btnLogin").click(function () {

             var uid = $("#uid").val();
             var pwd = $("#pwd").val();
             var code = $("#code").val();

             if (!uid) {
                 alert('用户名不能为空'); return false;
             }
             else if (!pwd) {
                 alert('密码不能为空'); return false;
             }
             else if (!code) {
                 alert('验证码不能为空'); return false;
             }
             var chk = false;
             if ($("#savepwd").attr('checked')) {
                 chk = true;
             }
             $.ajax({
                 type: "GET",
                 cache: false,
                 contentType: "application/json",
                 url: "ashx/AjaxLoginHandler.ashx",
                 dataType: 'json',
                 data: { "uid": uid, "pwd": pwd, "code": code, "chk": chk },
                 success: function (data) {
                     if (data == '201') {
                         getimgcode();
                         alert('验证码错误'); return false;
                     }
                     else if (data == '202') {
                         alert('用户名或者密码错误\r\n登录失败'); return false;
                     }
                     else {
                         window.location.href = 'StudyCenter.aspx';
                     }
                 }
             });
         });


         $("#btnSignOut").click(function () {
             var answer = confirm("是否退出?");
             if (answer) {

                 $.ajax({
                     type: "GET",
                     cache: false,
                     contentType: "application/json",
                     url: "ashx/StudentSignOutHandler.ashx",
                     dataType: 'json',
                     data: null,
                     async: false,
                     success: function (data) {
                         if (data != '200') {
                             alert('操作失败'); return false;
                         }
                         else {
                             var host = window.location.host;
                             window.location.href = "http://" + host + "/Index.aspx";
                         }
                     }
                 });
             }
         });
     });
     
     
     
</script>
    <div class="side">
        <% if(string.IsNullOrEmpty(htmlLoginBox.ToString()))
       {%>
        <div class="box203">
            <div class="titles">
                <img src="images/tit_yhdl.gif" alt="用户登录" /></div>
            <div class="conts side-login">
                <ul>
                    <li>
                        <label>
                            ID</label>
                        <div class="inputbox">
                            <input id="uid" class="textsty text01" name="" type="text" /></div>
                    </li>
                    <li>
                        <label>
                            PW</label>
                        <div class="inputbox">
                            <input id="pwd" class="textsty text01" name="" type="password" /></div>
                    </li>
                    <li>
                        <label>
                            VC</label>
                        <div class="inputbox">
                            <input id="code" class="textsty text02 fl" name="" type="text" />
                            <span class="fl">
                            &nbsp;&nbsp;
                                <img src="VerifyCode.aspx" alt="点击图片刷新验证码" style="cursor:pointer" onclick="this.src='VerifyCode.aspx?time='+Math.random();"  id="getcode"  /><%--<a href="javascript:getimgcode()"></a>--%>
                          
                            </span>
                        </div>
                    </li>
                </ul>
                <div class="btm">
                    <span>
                        <input id="savepwd" name="" type="checkbox" value=""/>
                        记住密码</span><%-- <a href="#">忘记密码？</a>--%>
                </div>
                <div class="button">
                    <input class="publicbtn btn-login" name=""  id="btnLogin" type="button" value="login" /></div>
            </div>
            <div class="box-bbg">
            </div>
        </div>  
         <% } %>
         <% else
           {%>
               <%= htmlLoginBox.ToString() %>
          <% } %>
        <ul class="side-mail">
            <li>
                <img src="images/i02.gif" />
                <a href="http://english.sjtu.edu.cn">english.sjtu.edu.cn</a></li>
            <li>
                <img src="images/i03.gif" />
                <a href="mailto:lianxi@sjtu.edu.cn">lianxi@sjtu.edu.cn</a></li>
        </ul>
        <dl class="side-time">
            <dt>运行时间</dt>
            <dd>
                <p>
                    <span class="tit">AM：</span><span>09:00-11:30</span></p>
                <p>
                    <span class="tit">PM：</span><span>09:00-11:30</span></p>
            </dd>
        </dl>
        <dl class="side-phone">
            <dt>有急事事宜可以联系下面电话</dt>
            <dd>
                <img src="images/phone.gif" alt="021-" /></dd>
        </dl>
    </div>
    <!--end side-->
    <div class="contents">
        <div class="home-cent">
            <dl class="home-news">
                <dt><span class="tit fl">
                    <img src="images/tit_xw.gif" alt="最新新闻" /></span><span class="more fr"><a href="Newslist.aspx"
                        ><img src="images/more.gif" alt="more" /></a></span></dt>
                <dd>
                <% if(NewsCollection!=null&&NewsCollection.Count>0)
                   {
                       htmlStr.Append(" <ul class=\"h-n-list\"> ");

                       foreach (var item in NewsCollection)
                       {

                           htmlStr.AppendFormat(
                               "<li><span class=\"date\">[{0}]</span><a href=\"Newscontent.aspx?id={2}\">{1}</a></li>",
                               item.OperatorTime.ToString("yyyy.MM.dd"),
                               item.Title, item.ID);
                       }
                       
                       htmlStr.Append(" </ul>");

                   } %>
                   <%=htmlStr.ToString()%>
                   <%-- <ul class="h-n-list">                      

                        <li><span class="date">[2012.09.01]</span><a href="#">有急事事宜可以联系下面电话</a></li>
                        <li><span class="date">[2012.09.01]</span><a href="#">有急事事宜可以联系下面电话</a></li>
                        <li><span class="date">[2012.09.01]</span><a href="#">有急事事宜可以联系下面电话</a></li>
                        <li><span class="date">[2012.09.01]</span><a href="#">有急事事宜可以联系下面电话</a></li>
                        <li><span class="date">[2012.09.01]</span><a href="#">有急事事宜可以联系下面电话</a></li>
                    </ul>--%>
                </dd>
            </dl>
            <div class="home-foc">
                <div id="home-foc">
                    <a class="focImg" href="#">
                        <img src="images/foc/foc01.jpg" width="461" height="207" alt="" /></a> <a class="focImg"
                            href="#">
                            <img src="images/foc/foc02.jpg" width="461" height="207" alt="" /></a> <a class="focImg"
                                href="#">
                                <img src="images/foc/foc03.jpg" width="461" height="207" alt="" /></a>
                    <ul class="homefoc_nav">
                        <li>1</li>
                        <li>2</li>
                        <li>3</li>
                    </ul>
                </div>
            </div>
            <!--end home-foc-->
        </div>
        <div class="home-right">
            <dl class="home-genius">
                <dt>
                    <img src="images/tit_qftc.gif" alt="勤奋天才" /></dt>
                <dd>
                  
                    <% if(DiligentRankCollection!=null&&DiligentRankCollection.Count>0)
                       {
                           htmlDiligentRank.Append("<ul>");
                           foreach (var studentRank in DiligentRankCollection)
                           {
                               htmlDiligentRank.AppendFormat("<li><a href=\"#\">{0}</a></li>",studentRank.UserName);
                           } htmlDiligentRank.Append("</ul>");
                       } %>

                       <%= htmlDiligentRank.ToString() %>

                        <%-- <ul>--%>
                        <%--<li><a href="#">勤奋天才</a></li>
                        <li><a href="#">勤奋天才</a></li>
                        <li><a href="#">勤奋天才</a></li>
                        <li><a href="#">勤奋天才</a></li>
                        <li><a href="#">勤奋天才</a></li>
                        <li><a href="#">勤奋天才</a></li>--%>
                    <%--</ul>--%>
                </dd>
            </dl>
            <!--end home-genius-->
            <dl class="home-bang">
                <dt>
                    <img src="images/tit_zyb.gif" alt="状元榜" /></dt>
                <dd>
                 <% if (ChampionRankCollection != null && ChampionRankCollection.Count > 0)
                       {
                           htmlChampionRank.Append("<ul>");
                           int i = 0;
                           var liCss = "";
                           foreach (var studentRank in ChampionRankCollection)
                           {
                               i += 1;
                               if (i > 2) i = 1;
                               liCss = string.Format("li_{0}", i);
                               htmlChampionRank.AppendFormat("<li class=\"{0}\">{1}</li>",liCss, studentRank.UserName);
                           }
                           htmlChampionRank.Append("</ul>");
                       } %>

                       <%= htmlChampionRank.ToString()%>
                    <%--<ul>
                        <li class="li_1">状元榜<br />
                            状元榜</li>
                        <li class="li_2">状元榜</li>
                        <li class="li_1">状元榜</li>
                        <li class="li_2">状元榜</li>
                    </ul>--%>
                </dd>
            </dl>
            <!--end home-bang-->
        </div>
    </div>
    <!--end contents-->
</asp:Content>
